//
//  GNTableHeaderFootView.m
//  GoldBook
//
//  Created by wmz on 2021/8/15.
//  Copyright © 2021 wmz. All rights reserved.
//

#import "GNTableHeaderFootView.h"

@interface GNTableHeaderFootView()

@property(nonatomic,strong)UILabel *leftLB;
@end

@implementation GNTableHeaderFootView

+ (instancetype)headerWithTableView:(UITableView *)tableView {
    NSString *ID = NSStringFromClass(self);
    GNTableHeaderFootView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:ID];
    if (!header) {
        header = [[self alloc] initWithReuseIdentifier:ID];
    }
    return header;
}
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        [self setupSubViews];
    }
    return self;
}
- (void)setupSubViews{
    [self.contentView addSubview:self.leftLB];
}

- (void)setGNModel:(HDTableHeaderFootViewModel*)data{
    self.model = data;
    self.leftLB.text = data.title;
    self.leftLB.textColor = PostColor(0x333333);
    self.leftLB.font = data.titleFont;
    self.leftLB.textAlignment = data.titleTextAlignment;
    self.contentView.backgroundColor = data.backgroundColor;
    [self.leftLB mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-self.model.edgeInsets.right);
        make.left.mas_offset(self.model.edgeInsets.left);
        make.top.mas_offset(self.model.edgeInsets.top);
        make.bottom.mas_offset(-self.model.edgeInsets.bottom);
    }];
}

- (UILabel *)leftLB{
    if (!_leftLB) {
        _leftLB = UILabel.new;
    }
    return _leftLB;
}


@end
